#version 450 core
out vec4 FragColor;
in vec2 texCoord;

uniform sampler2D yTexture;
uniform sampler2D uTexture;
uniform sampler2D vTexture;

void main() {

  float y = texture(yTexture, texCoord).r;
  float u = texture(uTexture, texCoord).r - 0.5;
  float v = texture(vTexture, texCoord).r - 0.5;

  mat3 matrix = mat3(1.0, 0.0, 1.402,
                     1.0, -0.344, -0.714,
                     1.0, 1.772, 0.0);
  //这里注意openGL默认存储是列优先
  vec3 rgb = vec3(y, u, v) * matrix;

  FragColor = vec4(rgb, 1.0f);
}
